/**
 * @author whailong  [wanghl@ncsi.com.cn]
 * @date 16 Jun 2014 19:53:41
 */
package com.surent.app;

import android.app.Application;
import android.content.Context;

import com.avos.avoscloud.AVOSCloud;
import com.avos.avoscloud.AVObject;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.surent.model.dbmodel.House;
import com.surent.model.dbmodel.Image;

/**
 * 
 * @author whailong [wanghl@ncsi.com.cn]
 * @date 16 Jun 2014 19:53:41
 */
public class SuRentApp extends Application {
	@Override
	public void onCreate() {
		super.onCreate();

		AVObject.registerSubclass(House.class);
		AVObject.registerSubclass(Image.class);

		AVOSCloud.initialize(getApplicationContext(), "7i1rlg5sy9kdg0diueouleb1dbapie4bjmseq40afc17ctmc",
				"8qeftw3kx0u5xs8wcwj09fubbhgfl5aed5ikol7cdeompw4q");
		initImageLoader(getApplicationContext());
	}

	/**
	 * 初始化UIL加载配置
	 * 
	 * @param context
	 */
	public void initImageLoader(Context context) {
		// This configuration tuning is custom. You can tune every option, you
		// may tune some of them,
		// or you can create default configuration by
		// ImageLoaderConfiguration.createDefault(this);
		// method.
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
				.threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory()
				.diskCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO)
				.writeDebugLogs() // Remove for release app
				.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);
	}
}
